<%@page import="java.text.SimpleDateFormat"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!doctype html>
<html>
	<head>
		<title>锁定列表 -- </title>
		<base href="<%=basePath%>" />
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="renderer" content="webkit">
		<meta http-equiv="Cache-Control" content="no-siteapp" />
		<link rel="apple-touch-icon-precomposed" href="i/app-icon72x72@2x.png">
		<meta name="apple-mobile-web-app-title" content="Amaze UI" />
		<link rel="stylesheet" href="layui/css/layui.css" media="all"> <!-- 适应所有设备 -->
		<style type="text/css">
		</style>
	</head>
	<%
	String today = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
%>
	<body>

        <br/>
		<div class="layui-form-item">
			<!-- 通过form id来调用js里ajax,来实现参数的传递 -->
			<form class="layui-form" id="banqueryForm" onsubmit="return false">
				<!-- 返回所有玩家信息 -->

				<div class="layui-form-item">
					<div class="layui-input-inline">
						<input type="text" name="ID" id="ID" placeholder="玩家ID" autocomplete="off" lay-filter="ID" class="layui-input">
					</div>
					<div class="layui-inline">
						<div class="layui-input-inline">
							<button class="layui-btn layui-btn-normal" data-type="reload" id="SelectOrder" onsubmit='return false'>搜索</button>
						</div>
					</div>
				</div>
			</form>
		</div>
		</div>
		<div class="layui-form">
			<table class="layui-table" lay-skin="nob" id="PlayerInfoshow" lay-filter="PlayerInfoshow"></table>
		</div>
		<div class="tpl-alert"></div>
	</body>

	<script src="js/jquery.min.js"></script>
	<script src="layui/layui.js"></script>
	<script src="js/personal/formsubmit.js"></script>
    <script id="barDemo">
        <a class="layui-btn layui-btn-xs" lay-event="edit">解封账号</a>
    </script>
    
    <script type="text/html" id="IsBusinessman">
            {{#  if(d.IsBusinessman === false){ }}
                <span class="layui-badge layui-bg-green">玩家</span>
            {{#  } else if(d.IsBusinessman === true){ }}
                <span class="layui-badge layui-bg-blue">会长</span>
            {{#  } }}
    </script>
    
	<script>
		layui.use(['layer', 'form', 'table'], function() {
			var layer = layui.layer,
				form = layui.form,
				table = layui.table;
            
			layer.config({
				extend: 'MySkin/style.css'
			});
			
			table.render({
				elem: '#PlayerInfoshow',
				url: 'pa/player_ban',
				method: 'post',
				cellMinWidth: 80,
				id: 'AllTable',
				request: {
					pageName: 'PageIndex',
					limitName: 'PageCount'
				},
				where: {
					ID: $('#ID').val()
				},
				cols: [[
					{field: 'UserId',title: '用户ID',},
					{field: 'Nickname',title: '用户昵称'},
					{field: 'IsBusinessman',title: '会长/商人',templet:'#IsBusinessman'},
					{field: 'Level',title: '等级'},
					{field: 'OperationTime',title: '操作时间'},
					{field: 'OperationReason',title: '操作原因'},
					{field: 'Operator',title: '操作人'},
					{field: 'Operator',title: '操作人'},
					{fixed: 'right',title: '操作',toolbar:'#barDemo'}
					]],
				page: true,
				response: {
					statusCode: 200
				},
				parseData: function(res) {
					return {
						"code": res.status,
						"msg": res.message,
						"count": res.count,
						"data": res.data
					};
				}
			});

			//根据条件查询表格数据重新加载
			var active = {
				reload: function() {
					//获取用户名
					//执行重载
					table.reload('AllTable', {
						page: {
							curr: 1 //重新从第 1 页开始
						}
						//根据条件查询
						,
						where: {
							ID: $('#ID').val()
						}
					});
					return false;
				}
			};
			//点击搜索按钮根据用户名称查询
			$('#SelectOrder').on('click',
				function() {
					var type = $(this).data('type');
					active[type] ? active[type].call(this) : '';
				});
			
			
			table.on('tool(PlayerInfoshow)',function(obj){
				var data = obj.data,
				layEvent = obj.event;
				if(layEvent == 'edit'){
					var id = data.UserId;
					var name = data.Nickname;
					var index = layer.open({
						type: 2,
						shadeClose: true,
						shade: 0.5,
						area: ['100%', '100%'],
						title: '解锁玩家',
						skin: 'layer-ext-yourskin',
						content: '<%=basePath%>pa/detail/playUnBlock',
						success: function(layero, index) {
							var body = layer.getChildFrame("body", index); //绑定父子页面
							// 取到弹出层里的元素，并把编辑的内容放进去
							body.find(".zid").val(id); //将选中的数据的id传到编辑页面的隐藏域，便于根据ID修改数据
							body.find(".zname").val(name);
							//parent.layer.close(index);//关闭子页面
						}
					});
				}
			});
		});
	</script>

</html>
